package com.zuokun.controller;

import com.zuokun.annotation.Controller;
import com.zuokun.annotation.ProtocolMapping;
import com.zuokun.protol.heartbeat.MsgPing;
import com.zuokun.protol.heartbeat.MsgPong;
import com.zuokun.protol.login.MsgGetAchieve;
import com.zuokun.protol.login.MsgLogin;
import com.zuokun.protol.login.MsgRegister;
import com.zuokun.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Controller
@Slf4j
public class LoginController {

    @Autowired
    private LoginService loginService;

    /**
     * 玩家登录
     * @param msgLogin
     * @return
     */
    @ProtocolMapping("MsgLogin")
    public MsgLogin login(MsgLogin msgLogin){
        return loginService.login(msgLogin);
    }

    /**
     * 玩家注册
     * @param msgRegister
     * @return
     */
    @ProtocolMapping("MsgRegister")
    public MsgRegister register(MsgRegister msgRegister){
        return loginService.register(msgRegister);
    }

    /**
     * 获取玩家信息
     * @param msgGetAchieve
     * @return
     */
    @ProtocolMapping("MsgGetAchieve")
    public MsgGetAchieve getPlayerInfo(MsgGetAchieve msgGetAchieve){
        return loginService.getPlayerInfo(msgGetAchieve);
    }

    /**
     * 心跳
     * @param msgPing
     * @return
     */
    @ProtocolMapping("MsgPing")
    public MsgPong ping(MsgPing msgPing){
        return new MsgPong();
    }
}
